var seletetreatmentUnitValue = $('#treatmentUnitValue').val();
if (seletetreatmentUnitValue != "") {
    $("#treatmentUnit option[value='" + seletetreatmentUnitValue + "']").attr("selected", "selected")
}
var seletefieldTc = $('#queryTcValue').val();
if (seletefieldTc != "") {
    $("#fieldTc option[value='" + seletefieldTc + "']").attr("selected", "selected")
}
addNatureCustomerCZ = function () {
    var fieldTc = document.getElementById("fieldTc").value;
    var reservationsId = document.getElementById("reservationsId").value;
    var treatmentUnit = document.getElementById("treatmentUnit").value;
    var customerName = document.getElementById("customerName").value;
    var remarks = document.getElementById("remarks").value;
    var seletetreatmentUnitValue = $('#treatmentUnitValue').val();
    var seletefieldTc = $('#fieldTcValue').val();
    if (treatmentUnit == null || treatmentUnit == "") {
        alert("请选择科室！");
        return
    }
    if (fieldTc == null || fieldTc == "") {
        alert("请选择TC！");
        return
    }
    if (fieldTc != seletefieldTc || treatmentUnit != seletetreatmentUnitValue) {
        if (remarks == null || remarks == "") {
            alert("请填写备注！");
            return
        }
    }
    var currentSeat = parent.parent.$('#currentSeat').html();
    $.ajax({
        url: Feng.ctxPath + "/customer/addNatureCustomerCZ",
        type: "post",
        data: {
            "reservationsId": reservationsId,
            "customerName": customerName,
            "treatmentUnit": treatmentUnit,
            "fieldTc": fieldTc,
            "remarks": remarks
        },
        success: function (data) {
            var ids=data.ids;
            if (ids == 0) {
                alert("该科室已存在不需要重咨！");
                return
            } else if (ids == 2) {
                alert("该患者今天已经分配过tc，不需要重咨！");
                return
            } else {
                Feng.success('添加成功!');
                if(data.status==1){
                    window.parent.register(data);
                }
                if (currentSeat == '到店 &gt; 预约视图') {
                    if(data.status == "1"){
                        window.parent.document.getElementById("childrenIframe").contentWindow.$('#calendar').fullCalendar('refetchEvents');
                    }else {
                        window.parent.$('#calendar').fullCalendar('refetchEvents');
                    }
                    $('#cancel', document).click()
                } else if (currentSeat == '到店 &gt; 患者信息' || currentSeat == '到店 &gt; 修改信息' || currentSeat == '到店 &gt; 市场预约') {
                    if(data.status == "1"){
                        window.parent.document.getElementById("childrenIframe").contentWindow.Customer.search();
                    }else {
                        window.parent.Customer.search();
                    }
                    $('#cancel', document).click()
                } else if (currentSeat == 'TC &gt; TC看诊') {
                    if(data.status == "1"){
                        window.parent.document.getElementById("childrenIframe").contentWindow.Consultant.search();
                    }else {
                        window.parent.Consultant.search();
                    }
                    $('#cancel', document).click()
                } else {
                    $('#cancel', document).click()
                }
            }
        },
        error: function (data) {
            alert('没有权限，请联系系统管理员!');
            $('#cancel', document).click()
        }
    })
};